#include "QRONode_P.h"

void QRONode::Private::valueToNet(QVariant& param)
{
    param = serilizeValue(param,[=](QObject* obj) ->ObjectID{
        if(!m_objectIdMap.contains(obj)) return NullID;
        auto localId = m_objectIdMap[obj];
        auto remoteId = m_remoteIdMapper.key(localId,NullID);
        return remoteId;
    });
}

void QRONode::Private::valueFromNet(QVariant& param,int targetType)
{
    param = unserilizeValue(param,[=](ObjectID id) ->QObject*{
            if(!m_remoteIdMapper.contains(id)) return NULL;
            auto localId = m_remoteIdMapper[id];
            if(!m_objectDataMap.contains(localId)) return NULL;

            auto data = m_objectDataMap[localId];

            return data->obj;
        },targetType);
}
